import fetch from "./http"

export async function httpopenLive(data) {
    try {
        let res = await fetch.post("/live/open",data);
        return res.data;
    }catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpIsOpenLive(data) {
    try {
        let res = await fetch.post("/live/checkUser",data);
        return res.data;
    }catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpCloseLive(data) {
    try {
        let res = await fetch.post("/live/remove",data);
        return res.data;
    }catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpaddPost(data) {
    try {
        let res = await fetch.post("/video/post/addPost",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpgetPostList(data) {
    try {
        let res = await fetch.post("/video/post/getList",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpGetLive(data) {
    try {
        let res = await fetch.post("/live/get",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpGetLiveList(data) {
    try {
        let res = await fetch.post("/live/list",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpRegisteUser(data) {
    try {
        let res = await fetch.post("/registe",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpLoginUser(data) {
    try {
        let res = await fetch.post("/login",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpAddVideo(data) {
    try {
        let res = await fetch.post("/video/addVideo",data);
        return res.data;
    }catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpGetVideoListByUserId(data) {
    try {
        let res = await fetch.post("/video/getVideoListByUserId",data);
        return res.data;
    }catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpGetVideoListWithURL(data) {
    try {
        let res = await fetch.post("/video/getVideoWithURL",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function getshowVideoAddr(data) {
    try {
        let res = await fetch.post("/video/getShowVideo",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}



export async function httpSearchLive(data) {
    try {
       let res = await fetch.post("/live/search",data);
       return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpSearchVideo(data) {
    try {
        let res = await fetch.post("/video/search",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpAddVideoComment(data) {
    try {
        let res = await fetch.post("/video/addVideoComment",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpGetVideoCommentList(data) {
    try {
        let res = await fetch.post("/video/getVideoCommentList",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpUpdatePostLikes(data) {
    try {
        let res = await fetch.post("/video/post/updatePostLikes",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpUpdatePostDislikes(data) {
    try {
        let res = await fetch.post("/video/post/updatePostDislikes",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpUpdateVideoCommentLikes(data) {
    try {
        let res = await fetch.post("/video/updateVideoCommentLikes",data)
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpUpdateVideoCommentDislikes(data) {
    try {
        let res = await fetch.post("/video/updateVideoCommentDiklikes",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpUpdataVideoLikes(data) {
    try {
        let res = await fetch.post("/video/updateVideoLikes",data);
    } catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpUpdataVideoDislikes(data) {
    try {
        let res = await fetch.post("/video/updateVideoDislikes",data);
    } catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpGetVideoById(data) {
    try {
        let res = await fetch.post("/video/getVideoById",data);  
        return res.data; 
    } catch(e) {
        console.log(e);
        return null;
    }
}


export async function httpGetUserInfoById(data) {
    try {
        let res = await fetch.post("/video/user/getUserInfoById",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpUpdateUserInfo(data) {
    try {
        let res = await fetch.post("/video/user/updateInfo",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpcheckNameNum(data) {
    try {
        let res = await fetch.post("/video/user/checkNameNum",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}

export async function httpRunCode(data) {
    try {
        let res = await fetch.post("/live/runCode",data);
        return res.data;
    } catch(e) {
        console.log(e);
        return null;
    }
}